// components/notice/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    notice:Object
  },

  /**
   * 组件的初始数据
   */
  data: {
    imgs:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    phoneCall() {
      wx.makePhoneCall({
        phoneNumber: this.data.notice.phone
      })
    },
    preImg(event) {
      let img = event.target.dataset.img
      wx.previewImage({
        urls:this.data.imgs,
        current:img
      })
    },
    detail() {
      wx.navigateTo({
        url: '../detail/index?id=' + this.data.notice.noticeId,
      })
    },
    // 跳转到公告分类上去
    categoryList(event) {
      let cid = event.target.dataset.cid
      let cname = event.target.dataset.cname
      wx.navigateTo({
        url: '../category/index?cid='+cid+'&cname='+cname,
      })
    }
  },
  // 页面完成，初始化图片
  ready() {
    // console.log(this.properties.notice.img)
    if (this.properties.notice.img != null && this.properties.notice.img != '') {
      this.setData({
        imgs: this.properties.notice.img.split(','),
      })
    }
  }
})
